package com.cn.byjk.service;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author zhangdianzhi
 * @version v1.0
 * @description
 * @date 2022/1/08 10:37
 */
@Service
@EnableBinding(Source.class)
public class SendMessageService {
    @Resource
    private MessageChannel output; //发送消息管道


    public String send() {
        String serial = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("******serial: "+serial);
        return serial;
    }
}
